package com.taoyi.mhouse.fragments;

import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;

import android.os.Handler;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.taoyi.mhouse.R;
import com.taoyi.mhouse.util.UIUtils;

import java.util.Random;

/**
 * Created by tempo on 2015/11/11.
 */
public class ForumFragment extends LoadingFreshingFragment {

    Handler handler=new Handler();

    private String data;
    @Override
    public void loadData(final LoadingCallback callback) {
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                Random rand = new Random();
                int i= rand.nextInt(5);
                if(i==0) {
                    callback.setResult(ResultState.Empty,null);
                }else if(i==1){
                    callback.setResult(ResultState.Error,null);
                }else{
                    data = "ok success";
                    callback.setResult(ResultState.Success, data);
                }

            }
        },800);
    }

    @Override
    public View getSuccessView(View parent, Object data) {
        return LayoutInflater.from(UIUtils.getContext()).inflate(R.layout.fragment_forum,null);
    }


    @Override
    protected void clearData() {
        data=null;
    }

}
